package risk.control.application.http;


import org.apache.commons.codec.digest.DigestUtils;

import java.util.HashMap;

import risk.control.application.utils.DeviceUtils;

public class SessionHelp {
    public static HashMap<String, String> getParams() {
        String timestamp = String.valueOf(System.currentTimeMillis());
        String appVersion = DeviceUtils.getAppVersion();
        String channel = "Android";//通道标识
        String osVersion = DeviceUtils.getOsVersion();
        String apiLevel = DeviceUtils.getApiLevel();
        String screenWidth = DeviceUtils.getScreenWidth();
        String screenHeight = DeviceUtils.getScreenHeight();
        String manufacturer = DeviceUtils.getManufacturer();
        String deviceUniqueId = DeviceUtils.getDeviceUniqueId();

        String signature = timestamp.toLowerCase() //
                + screenHeight.toLowerCase() //
                + appVersion.toLowerCase()//
                + osVersion.toLowerCase() //
                + deviceUniqueId.toLowerCase()//
                + screenWidth.toLowerCase()//
                + channel.toLowerCase()//
                + manufacturer.toLowerCase()//
                + apiLevel.toLowerCase()//
                + timestamp.toLowerCase(); //

        HashMap<String, String> paramsMap = new HashMap<>();
        paramsMap.put("timestamp", timestamp);
        paramsMap.put("appVersion", appVersion);
        paramsMap.put("channel", channel);
        paramsMap.put("osVersion", osVersion);
        paramsMap.put("apiLevel", apiLevel);
        paramsMap.put("screenWidth", screenWidth);
        paramsMap.put("screenHeight", screenHeight);
        paramsMap.put("manufacturer", manufacturer);
        paramsMap.put("deviceUniqueId", deviceUniqueId);
        paramsMap.put("signature", DigestUtils.md5Hex(signature));
        return paramsMap;
    }

}
